<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>代理设置</title>
    <link rel="stylesheet" type="text/css" href="/static/agent/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/static/agent/css/select.css" />
</head>

<body>
<div class="layui-inline" style="padding-left: 9.1%;padding-top: 2%">
    <form class="layui-form layui-form-pane" action="javascript:;">
        <div class="layui-form-item">
            <label class="layui-form-label">代理设置</label>
            <div class="layui-input-block">
                {eq name="$userc.user_role" value="0" }
                <input type="radio" name="user_role" value="0" title="普通用户" checked>
                <input type="radio" name="user_role" value="3" title="县级代理" >
                <input type="radio" name="user_role" value="2" title="市级代理" >
                <input type="radio" name="user_role" value="1" title="省级代理" >
                {/eq}
                {eq name="$userc.user_role" value="1" }
                <input type="radio" name="user_role" value="0" title="普通用户" >
                <input type="radio" name="user_role" value="3" title="县级代理">
                <input type="radio" name="user_role" value="2" title="市级代理" >
                <input type="radio" name="user_role" value="1" title="省级代理" checked>
                {/eq}
                {eq name="$userc.user_role" value="2" }
                <input type="radio" name="user_role" value="0" title="普通用户" >
                <input type="radio" name="user_role" value="3" title="县级代理" >
                <input type="radio" name="user_role" value="2" title="市级代理" checked>
                <input type="radio" name="user_role" value="1" title="省级代理" >
                {/eq}
                {eq name="$userc.user_role" value="3" }
                <input type="radio" name="user_role" value="0" title="普通用户" >
                <input type="radio" name="user_role" value="3" title="县级代理" checked>
                <input type="radio" name="user_role" value="2" title="市级代理" >
                <input type="radio" name="user_role" value="1" title="省级代理">
                {/eq}
            </div>
        </div>
        <div class="layui-form-item" id="addressDiv">
            <div class="layui-input-inline" id="sheng">
                <select name="P1" lay-filter="province" id="province">
                    <option></option>
                </select>
            </div>
            <div class="layui-input-inline" id="shi">
                <select name="C1" lay-filter="city" id="city">
                    <option></option>
                </select>
            </div>
            <div class="layui-input-inline" id="qu">
                <select name="A1" lay-filter="area" id="area">
                    <option></option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo" style="float: right;">确定</button>
            </div>
        </div>
    </form>
    <script src="/static/manager/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/agent/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="/static/agent/js/select.js" type="text/javascript" charset="utf-8"></script>
</div>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.on('radio', function(data){
            //console.log(data.value);
            if(data.value==0){
                $("#sheng").hide();
                $("#shi").hide();
                $("#qu").hide();
            }else if(data.value==3){
                $("#sheng").show();
                $("#shi").show();
                $("#qu").show();
            }else if(data.value==2){
                $("#sheng").show();
                $("#shi").show();
                $("#qu").hide();
            }else {
                $("#sheng").show();
                $("#shi").hide();
                $("#qu").hide();
            }
        });
        //监听提交
        form.on('submit(formDemo)', function(data){
            //layer.msg(JSON.stringify(data.field));
            //alert(data.field.user_role);
            $.post("/manager/Index/num_agent_do",{
                user_id:{$userc.user_id},
                user_role:data.field.user_role,
                a:data.field.P1,
                b:data.field.C1,
                c:data.field.A1
            },function(result){
                if(result==200){
                    alert("代理设置成功！");
                    parent.window.location.reload();
                }else {
                    alert("信息更改失败！");
                }
            });
            return false;
        });
    });
</script>
</body>

</html>